﻿namespace _4
{
    internal class Program
    {
        class Toeplitz{
            public void GetMatrix(out int[,] Mat,out int Line,out int Row )
            {
                int line = 0;int row = 0;
                Console.Write("Please enter the line number of the matrix:");
                line = int.Parse(Console.ReadLine());
                Console.Write("Please enter the row number of the matrix:");
                row = int.Parse(Console.ReadLine());
                int[,] mat = new int[line,row];
                int sum = 0;
                Console.WriteLine("Please enter the matrix:");
                for (int i = 0; i < line; i++)
                {
                    string s = "";
                    s = Console.ReadLine();
                    string[] arr1 = s.Split(' ');
                    int len = arr1.Length;
                    for (int j = 0; j < len; j++)
                    {
                        mat[i,j] = int.Parse(arr1[j]);
                    }
                }
                Mat = mat;
                Line = line;
                Row = row;
            }

            public bool JudgeMatrix(int[,] mat, int line, int row)
            {
                bool res = true;
                for (int i = 0; i < line; i++)
                {
                    for (int j = 0; j < row; j++)
                    {
                        if (i >= line - 1 || j >= row - 1)
                            continue;
                        else if (mat[i, j] != mat[i + 1, j + 1])
                        {
                            res = false;
                        }
                        else continue;
                    }
                }
                return res;
            }

            //public void WriteMatrix(int[,] mat, int line, int row)
            //{
            //    for (int i = 0; i < line; i++)
            //    {
            //        for (int j = 0; j < row; j++)
            //        {
            //            Console.Write(mat[i, j] + " ");
            //        }
            //        Console.WriteLine("");
            //    }
            //}
        }
        static void Main(string[] args)
        {
            Toeplitz obj = new Toeplitz();
            int[,] mat;int line;int row;
            obj.GetMatrix(out mat,out line,out row);
            //obj.WriteMatrix(mat, line, row);
            bool result = obj.JudgeMatrix(mat, line, row);
            //Console.WriteLine(result);
            if (result)
                Console.WriteLine("The matrix is Toeplitz matrix.");
            else
                Console.WriteLine("The matrix is not Toeplitz matrix.");
        }
    }
}
